/**
 * Created by Sxd on 2014/10/15.
 */

var netStruct = netStruct || {};
var vo = vo || {};

/**
 * @class
 * @extends cc.Class
 */
vo.BaseStruct = cc.Class.extend(/** @lends vo.BaseStruct */{

    ctor: function () {

    },

    serialize: function (data) {
        if (!data) {
            data = new xinyou.Packet();
        }
        return data;
    },

    /**
     * @param {xinyou.Packet} data
     */
    deserialize: function (data) {
        this.readBody(data);
        if (data.bytesAvailable) throw this + '还有 ' + data.bytesAvailable + ' 个字节未读取';
    },

    /**
     * @param {xinyou.Packet} data
     */
    readBody: function (data) {

    }
});
/**
 * @class
 * @extends vo.BaseStruct
 */
netStruct.NetStruct = vo.BaseStruct.extend(/** @lends netStruct.NetStruct */{
    msgCode: 0,

    ctor: function (msgCode) {
        this.msgCode = msgCode;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.LogonSuccess = netStruct.NetStruct.extend({});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.LogonFail = netStruct.NetStruct.extend({

    errorCode: 0,
    errorDesc: '',
    /**
     * @param {xinyou.Packet} data
     */
    readBody: function (data) {
        this.errorCode = data.readInt();
        this.errorDesc = data.readString();
    }
});

/**
 * 商城商品显示结构
 */
netStruct.GoodStruct = netStruct.NetStruct.extend({
    /**
     * 显示页面 byte
     */
    showType: null,
    /**
     * 总数 int
     */
    itemCount: 0,
    /**
     * 商品ID long
     */
    goodID: 0,
    /**
     * 商品图标ID int
     */
    goodIconID: 0,
    /**
     * 价格数量 int
     */
    priceQuantity: 0,
    /**
     * 商品数量 int
     */
    goodQuantity: 0,
    /**
     * 商品状态 int
     */
    goodState: 0,
    /**
     * 商品类型 int
     */
    goodType: null,
    /**
     * 价格类型 int
     */
    priceType: null,
    /**
     * 商品图标地址 string
     */
    goodIconPath: null,
    /**
     * 商品名称 string
     */
    goodName: null,
    /**
     * 商品
     */
    goods: [],

    readBody: function (data) {
        if (data.length == 2) {
            this.showType = data.readByte();
            this.itemCount = data.readInt();
            this.goods = [];
        }
        else {
            this.showType = data.readByte();
            this.itemCount = data.readInt();
            for (var a = 0; a < this.itemCount; a++) {
                this.goods[a] = this.getGoodInfo(data);
            }
        }
    },

    getGoodInfo: function (data) {
        this.goodID = data.readULong64();
        this.goodIconID = data.readInt();
        this.priceQuantity = data.readInt();
        this.goodQuantity = data.readInt();
        this.goodState = data.readInt();
        this.goodType = data.readInt();
        this.priceType = data.readInt();
        this.goodIconPath = data.readMyString();
        this.goodName = data.readMyString();

        var good = [this.goodID, this.goodIconID, this.priceQuantity, this.goodQuantity, this.goodState,
            this.goodType, this.priceType, this.goodIconPath, this.goodName];
        cc.log("商品ID："+this.goodIconID+"  "+this.goodID)
        return good;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.QuickCharge = netStruct.NetStruct.extend({
    itemCount: 0,

    diamond: 0,
    gold: 0,
    money: 0,

    goods: [],

    readBody: function (data) {
        if (data.length == 0)
            this.goods = [];
        else {
            this.itemCount = data.readByte();
            for (var a = 0; a < this.itemCount; a++) {
                this.goods[a] = this.getGoodInfo(data);
            }
        }
    },

    getGoodInfo: function (data) {
        this.diamond = data.readInt();
        this.gold = data.readInt();
        this.money = data.readInt();

        var good = [this.diamond, this.gold, this.money];

        return good;
    }
});

/**
 * @class
 * @extends netSturct.NetStruct
 */
netStruct.GoldExchange = netStruct.NetStruct.extend({
    itemCount: 0,

    diamond: 0,
    voucher: 0,
    gold: 0,

    goods: [],

    readBody: function (data) {
        if (data.length == 0)
            this.goods = [];
        else {
            this.itemCount = data.readByte();
            for (var a = 0; a < this.itemCount; a++) {
                this.goods[a] = this.getGoodInfo(data);
            }
        }
    },

    getGoodInfo: function (data) {
        this.diamond = data.readInt();
        this.gold = data.readInt();
        this.money = data.readInt();

        var good = [this.diamond, this.gold, this.money];

        return good;
    }
});

/**
 * @class
 * @extends netSturct.NetStruct
 */
netStruct.PropExchange = netStruct.NetStruct.extend({
    itemCount: 0,

    goodID: 0,
    iconID: 0,
    goodPrice: 0,
    priceType: 0,

    iconPath: null,
    goodName: null,
    goodState: null,
    goodType: null,

    goods: [],

    readBody: function (data) {
        if (data.length == 0)
            this.goods = [];
        else {
            this.itemCount = data.readByte();
            for (var a = 0; a < this.itemCount; a++) {
                this.goods[a] = this.getGoodInfo(data);
            }
        }
    },

    getGoodInfo: function (data) {
        this.goodID = data.readULong64();
        this.iconID = data.readInt();
        this.goodPrice = data.readInt();
        this.priceType = data.readInt();

        this.iconPath = data.readMyString();
        this.goodName = data.readMyString();
        this.goodState = data.readMyString();
        this.goodType = data.readMyString();

        var good = [this.goodID, this.iconID, this.goodPrice, this.priceType,
            this.iconPath, this.goodName, this.goodState, this.goodType];

        return good;
    }
});

/**
 * @class
 * @extends netSturct.NetStruct
 */
netStruct.PhysicalExchange = netStruct.NetStruct.extend({
    itemCount: 0,

    goodID: 0,
    iconID: 0,
    goodPrice: 0,
    priceType: 0,

    iconPath: null,
    goodName: null,
    goodState: null,
    goodType: null,

    goods: [],

    readBody: function (data) {
        if (data.length == 0)
            this.goods = [];
        else {
            this.itemCount = data.readByte();
            for (var a = 0; a < this.itemCount; a++) {
                this.goods[a] = this.getGoodInfo(data);
            }
        }
    },

    getGoodInfo: function (data) {
        this.goodID = data.readULong64();
        this.iconID = data.readInt();
        this.goodPrice = data.readInt();
        this.priceType = data.readInt();

        this.iconPath = data.readMyString();
        this.goodName = data.readMyString();
        this.goodState = data.readMyString();
        this.goodType = data.readMyString();

        var good = [this.goodID, this.iconID, this.goodPrice, this.priceType,
            this.iconPath, this.goodName, this.goodState, this.goodType];

        return good;
    }
});

/**
 * 商城商品购买结构 第一页
 */
netStruct.GoodBuyCZ = netStruct.NetStruct.extend({
    /**
     * 购买结果  int  1 成功生成订单号 2 已购买破产礼包 3 已购买新手礼包
     */
    result: null,
    /**
     * 订单号  string
     */
    billNumber: null,


    readBody: function (data) {
        if (data.length == 0)
            return;
        this.result = data.readInt();
        this.billNumber = data.readMyString();
    }
});

/**
 * 商城商品购买结构 第二页
 */
netStruct.GoodBuyJB = netStruct.NetStruct.extend({
    /**
     * 结束时钻石数量
     */
    diamond: null,
    /**
     * 参赛券
     */
    cansaiquan: null,
    /**
     * 结束时兑换券数量
     */
    voucher: null,
    /**
     * 结束时金币数量
     */
    gold: null,
    /**
     * 购买结果  int    0 成功 1 钻石不足 2 兑换券不足
     */
    result: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.cansaiquan = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.result = data.readInt();
    }
});

/**
 * 商城商品购买结构 第三页
 */
netStruct.GoodBuyDJ = netStruct.NetStruct.extend({
    /**
     * 结束时钻石数量
     */
    diamond: null,
    /**
     * 参赛券
     */
    cansaiquan: null,
    /**
     * 结束时兑换券数量
     */
    voucher: null,
    /**
     * 结束时金币数量
     */
    gold: null,
    /**
     * 购买结果  int    0 成功 1 钻石不足 2 兑换券不足
     */
    result: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.cansaiquan = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.result = data.readInt();
    }
});

/**
 * 商城商品购买结构 第四页
 */
netStruct.GoodBuySW = netStruct.NetStruct.extend({
    /**
     * 结束时钻石数量
     */
    diamond: null,
    /**
     * 结束时兑换券数量
     */
    voucher: null,
    /**
     * 结束时金币数量
     */
    gold: null,
    /**
     * 兑换码
     */
    code: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.code = data.readMyString();
    }
});

/**
 * 商城商品详细信息
 */
netStruct.GoodInfo = netStruct.NetStruct.extend({
    /**
     * 商城商品详细信息
     */
    content: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.content = data.readMyString();
    }
});

/**
 * 个人信息 我的道具
 */
netStruct.MyProp = netStruct.NetStruct.extend({
    /**
     * 道具个数 int
     */
    goodCount: null,
    /**
     * 道具图标ID int
     */
    goodIconID: null,
    /**
     * 商品ID long
     */
    goodID: null,
    /**
     * 商品数量 int
     */
    goodQuantity: null,
    /**
     * 商品状态 int
     */
    goodState: null,
    /**
     * 商品外部可用状态 byte
     */
    goodUseState: null,
    /**
     * 商品图标地址 string
     */
    goodIconPath: null,
    /**
     * 商品名称 string
     */
    goodName: null,

    /**
     * 我的道具数组
     */
    props: [],

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.goodCount = data.readInt();
        for (var a = 0; a < this.goodCount; a++) {
            this.props[a] = this.getPropInfo(data);
        }
    },

    getPropInfo: function (data) {
        this.goodIconID = data.readInt();
        this.goodID = data.readULong64();
        this.goodQuantity = data.readInt();
        this.goodState = data.readInt();
        this.goodUseState = data.readByte();
        this.goodIconPath = data.readMyString();
        this.goodName = data.readMyString();

        var prop = [this.goodIconID, this.goodID, this.goodQuantity, this.goodState, this.goodUseState, this.goodIconPath, this.goodName];
        return prop;
    }
});


/**
 * 商品支付信息
 */
netStruct.PayInfo = netStruct.NetStruct.extend({
    /**
     * 金钱 int
     */
    money: null,
    /**
     * 商品名字 string
     */
    goodName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.money = data.readInt();
        this.goodName = data.readMyString();
    }
});

/**
 * 商品支付结果
 */
netStruct.PayResult = netStruct.NetStruct.extend({
    /**
     * payGoodID int   大礼包ID
     */
    payGoodID: null,
    /**
     * 结果 int
     */
    result: null,
    /**
     * itemCount int
     */
    itemCount: null,
    /**
     * 商品集合 []
     */
    goods: [],
    /**
     * goodID int
     */
    goodID: null,
    /**
     * goodCount int
     */
    goodCount: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.payGoodID = data.readInt();
        this.result = data.readInt();
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount; a++) {
            this.goods[a] = this.getGoodInfo(data);
        }
    },

    getGoodInfo: function (data) {
        this.goodID = data.readInt();
        this.goodCount = data.readInt();

        var good = [this.goodID, this.goodCount];

        return good;
    }
});

/**
 * 使用道具
 */
netStruct.UseProp = netStruct.NetStruct.extend({
    /**
     * 钻石 int
     */
    diamond: null,
    /**
     * 参赛券 int
     */
    cansaiquan: null,
    /**
     * 兑换券 int
     */
    voucher: null,
    /**
     * 金币 int
     */
    gold: null,
    /**
     * 结果 int
     */
    result: null,
    /**
     * goodID long
     */
    goodID: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.cansaiquan = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.result = data.readInt();
        this.goodID = data.readULong64();
    }
});

/**
 * 使用道具
 */
netStruct.BeforeUseProp = netStruct.NetStruct.extend({
    /**
     * 商品单价数 long
     */
    goodID: null,
    /**
     * 商品单价数 int
     */
    goodPrice: null,
    /**
     * 商品价格类型 int  0 金币，1 钻石，2，兑换券
     */
    goodPriceType: null,
    /**
     * 商品剩余数量 int
     */
    goodRestCount: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.goodID = data.readULong64();
        this.goodPrice = data.readInt();
        this.goodPriceType = data.readInt();
        this.goodRestCount = data.readInt();
    }
});

/**
 * 使用喇叭
 */
netStruct.UseLaba = netStruct.NetStruct.extend({
    /**
     * 聊天类型 int
     */
    chatType: null,
    /**
     * 用户ID long
     */
    isVip:null,
    userId: [],
    /**
     * 聊天内容 string
     */
    chatContent: null,
    /**
     * 昵称 string
     */
    headPath:null,
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.chatType = data.readInt();
        this.isVip = data.readBoolean();
        for (var a = 0; a < 8; a++) {
            this.userId.push(data.readByte());
        }
        this.chatContent = data.readMyString();
        this.headPath = data.readMyString();
        this.nickName = data.readMyString();
    }
});

/**
 * 记牌器结构
 */
netStruct.PokeCount = netStruct.NetStruct.extend({
    /**
     * 结果 byte   1:可以用  0:不可用
     */
    result: null,
    /**
     * 结果 pokeType  int  0:进游戏  1：游戏中
     */
    pokeType: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.result = data.readByte();
        this.pokeType = data.readInt();
    }
});

/**
 * 使用道具结果
 */
netStruct.UsePropResult = netStruct.NetStruct.extend({
    /**
     * 结果
     */
    result: null,
    /**
     * 谁使用 byte
     */
    fromIndex: null,
    /**
     * 对谁使用 byte
     */
    toIndex: null,
    /**
     * 结果 pokeType  int  0:进游戏  1：游戏中
     */
    goodID: null,
    /**
     * 是否用了钱 isUseMoney  int  0:花钱  1：没花
     */
    isUseMoney: null,
    /**
     * goodPrice  int
     */
    goodPrice: null,

    readBody: function (data) {
        if (data.length == 0) {
            this.result = 0;
            return;
        }
        this.fromIndex = data.readByte();
        this.toIndex = data.readByte();
        this.goodID = data.readInt();
        this.isUseMoney = data.readInt();
        this.goodPrice = data.readInt();
    }
});

/**
 * 签到页面结构
 */
//qq签到页面的结构体！！！
netStruct.MySign = netStruct.NetStruct.extend({
    /**
     * 个数 int
     */
    itemCount: null,
    /**
     * 连续签到天数 int
     */
    continueSum: null,
    /**
     * 签到奖励ID long  1 金币 2 钻石  3兑换券  4参赛券
     */
    signRewardId: null,
    /**
     * 签到奖励类型 int   0 不能领  1 可以领 2 已经领过
     */
    signRewardType: null,
    /**
     * 签到数 int
     */
    sum: null,

    /**
     * 签到结构体
     */
    signs: [],

    /**
     * 签到天数 int
     */
    signCount: null,
    /**
     * 漏签到天数 int
     */
    lostSignCount: null,
    /**
     * 连续签到天数 int
     */
    comboSignCount: null,
    /**
     * 是否能签到 1 可以  0 不可以
     */
    canSign: null,
    /**
     * VIP剩余免补签次数 int
     */
    vipFreeBuSign: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount; a++) {
            this.signs[a] = this.getSignInfo(data);
        }

        this.signCount = data.readInt();
        this.lostSignCount = data.readInt();
        this.comboSignCount = data.readInt();
        this.canSign = data.readByte();
        this.vipFreeBuSign = data.readInt();
    },

    getSignInfo: function (data) {
        this.continueSum = data.readInt();
        //this.goodID = data.readULong64();
        //this.rewardQuantity = data.readInt();
        this.signRewardId = data.readULong64();
        this.signRewardType = data.readInt();
        this.sum = data.readInt();

        var sign = [this.continueSum, this.signRewardId, this.signRewardType, this.sum];

        return sign;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.SetSign = netStruct.NetStruct.extend({
    /**
     * 签到成功 byte
     */
    isSign: null,
    /**
     * 补签卡数量 int
     */
    buSignPropCount: null,
    /**
     * item个数  int
     */
    itemCount: null,
    /**
     * 奖励集合
     */
    signRewards: [],
    /**
     * 奖励ID long
     */
    signRewardId: null,
    /**
     * 奖励type int 0 不能领  1 可以领 2 已经领过
     */
    signRewardType: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.isSign = data.readByte();
        this.buSignPropCount = data.readInt();
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount; a++) {
            this.signRewards[a] = this.getSignRewards(data);
        }
    },

    getSignRewards: function (data) {
        this.signRewardId = data.readULong64();
        this.signRewardType = data.readInt();

        var signReward = [this.signRewardId, this.signRewardType];

        return signReward;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetSign = netStruct.NetStruct.extend({
    /**
     * 钻石 int
     */
    diamond: null,
    /**
     * 兑换券 int
     */
    voucher: null,
    /**
     * 金币 int
     */
    gold: null,
    /**
     * 结果  int   0 成功  1 领取过  2 未达到
     */
    result: null,
    /**
     * 结构个数 int
     */
    itemCount: null,
    /**
     * 结构
     */
    rewards: [],
    /**
     * 结构ID long
     */
    rewardID: null,
    /**
     * 结构类型 int
     */
    rewardType: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.result = data.readInt();
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount; a++) {
            this.rewards[a] = this.getRewards(data);
        }
    },

    getRewards: function (data) {
        this.rewardID = data.readULong64();
        this.rewardType = data.readInt();

        var reward = [this.rewardID, this.rewardType];

        return reward;
    }
});

/**
 * Rank
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetRank = netStruct.NetStruct.extend({
    /**
     * 显示页面 int
     */
    showType: null,
    /**
     * 集合个数 int
     */
    itemCount: null,
    /**
     * 集合
     */
    ranks: [],
    /**
     * 图标ID int
     */
    iconID: null,
    /**
     * 商品ID int
     */
    goodID: null,
    /**
     * 排名依据的数量 int 依据积分排名
     */
    rankCount: null,
    /**
     * 奖励数量 int
     */
    goodCount: null,
    /**
     * 排名  int
     */
    currentRank: null,
    /**
     * 用户ID long
     */
    userID: null,
    /**
     * 头像 string
     */
    headPath: null,
    /**
     * 昵称 string
     */
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.ranks = [];
        this.showType = data.readInt();
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount; a++) {
            this.ranks[a] = this.getRanks(data);
        }
    },

    getRanks: function (data) {
        this.iconID = data.readInt();
        this.goodID = data.readInt();
        this.rankCount = data.readInt();
        this.goodCount = data.readInt();
        this.currentRank = data.readInt();
        this.userID = data.readLong();
        this.headPath = data.readMyString();
        this.nickName = data.readMyString();

        var rank = [this.iconID, this.goodID, this.rankCount, this.goodCount, this.currentRank, this.userID,this.headPath, this.nickName];

        return rank;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetMission = netStruct.NetStruct.extend({
    /**
     *missionType int 游戏中任务显示 2      大厅任务显示 3
     */
    missionType: null,
    /**
     * roomType int  麻将 0  斗地主 1  德州扑克 2 所有 3
     */
    roomType: null,
    /**
     * missionLevel int 任务等级
     */
    missionLevel: null,
    /**
     * itemCount int 任务个数
     */
    itemCount: null,
    /**
     * 任务集合
     */
    missions: [],
    /**
     * missionIconID 任务图标id int
     */
    missionIconID: null,
    /**
     * missionID 任务id long
     */
    missionID: null,
    /**
     * missionTimes 领取任务需完成几次   int
     */
    missionTimes: null,
    /**
     * userTimes 用户当前任务完成次数  int
     */
    userTimes: null,
    /**
     * 奖励个数 int
     */
    rewardItemCount: null,
    /**
     * rewardID 奖励道具id   int
     */
    rewardID: null,
    /**
     * rewardCount 奖励道具数量   int
     */
    rewardCount: null,
    /**
     * missionName 任务名字  string
     */
    missionName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.missionType = data.readInt();
        this.roomType = data.readInt();
        this.missionLevel = data.readInt();
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount; a++) {
            this.missions[a] = this.getMissions(data);
        }
    },

    getMissions: function (data) {
        var rewards = [];
        this.missionIconID = data.readInt();
        this.missionID = data.readULong64();
        this.missionTimes = data.readInt();
        this.userTimes = data.readInt();
        this.rewardItemCount = data.readInt();
        for (var b = 0; b < this.rewardItemCount / 2; b++) {
            rewards[b] = this.getRewards(data);
        }
        this.missionName = data.readMyString();

        var mission = [this.missionIconID, this.missionID, this.missionTimes, this.userTimes, this.rewardItemCount, rewards, this.missionName];

        return mission;
    },

    getRewards: function (data) {
        this.rewardID = data.readInt();
        this.rewardCount = data.readInt();

        var reward = [this.rewardID, this.rewardCount];

        return reward;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetMissionReward = netStruct.NetStruct.extend({
    /**
     * 钻石数量  int
     */
    diamond: null,
    /**
     * 兑换券数量  int
     */
    voucher: null,
    /**
     * 金币数量  int
     */
    gold: null,
    /**
     * 结果   int  1 成功  0 失败
     */
    result: null,
    /**
     * missionIconID 任务图标id int
     */
    missionIconID: null,
    /**
     * missionID 任务id long
     */
    missionID: null,
    /**
     * missionTimes 领取任务需完成几次   int
     */
    missionTimes: null,
    /**
     * userTimes 用户当前任务完成次数  int
     */
    userTimes: null,
    /**
     * 奖励个数 int
     */
    rewardItemCount: null,
    /**
     * 奖励集合
     */
    rewards: [],
    /**
     * rewardID 奖励道具id   int
     */
    rewardID: null,
    /**
     * rewardCount 奖励道具数量   int
     */
    rewardCount: null,
    /**
     * missionName 任务名字  string
     */
    missionName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.result = data.readInt();
        this.missionIconID = data.readInt();
        this.missionID = data.readULong64();
        this.missionTimes = data.readInt();
        this.userTimes = data.readInt();
        this.rewardItemCount = data.readInt();
        for (var a = 0; a < this.rewardItemCount / 2; a++) {
            this.rewards[a] = this.getRewards(data);
        }
        this.missionName = data.readMyString();
    },

    getRewards: function (data) {
        this.rewardID = data.readInt();
        this.rewardCount = data.readInt();

        var reward = [this.rewardID, this.rewardCount];

        return reward;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.InnerMission = netStruct.NetStruct.extend({
    /**
     * diamond 钻石 int
     */
    diamond: null,
    /**
     * entryTicket 参赛券 int
     */
    entryTicket: null,
    /**
     * voucher 兑换券 int
     */
    voucher: null,
    /**
     * gold 金币 int
     */
    gold: null,
    /**
     * isVIP 是否VIP bool
     */
    isVIP: null,
    /**
     * result 结果 int
     */
    result: null,
    /**
     * missionID 任务ID long
     */
    missionID: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.entryTicket = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.isVIP = data.readBoolean();
        this.result = data.readInt();
        this.missionID = data.readULong64();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetGameMissionReward = netStruct.NetStruct.extend({
    /**
     * diamond 钻石 int
     */
    diamond: null,
    /**
     * 兑换券数量  int
     */
    voucher: null,
    /**
     * 金币数量  int
     */
    gold: null,
    /**
     * 结果   int  1 有任务出发领取  0 没有任务出发领取
     */
    result: null,
    /**
     * missionID 任务id long
     */
    missionID: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.result = data.readInt();
        this.missionID = data.readULong64();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetFriend = netStruct.NetStruct.extend({
    /**
     * itemCount 好友个数 int
     */
    itemCount: null,
    /**
     * friends 好友
     */
    friends: [],
    /**
     * diamond 好友 钻石 int
     */
    diamond: null,
    /**
     * voucher 好友 兑换券 int
     */
    voucher: null,
    /**
     * friendID 好友ID long
     */
    friendID: null,
    /**
     * gold 好友 金币 int
     */
    gold: null,
    /**
     * headImageID 好友 头像ID long
     */
    headImageID: null,
    /**
     * gender 好友 性别 string
     */
    gender: null,
    /**
     * headImagePath 好友 头像路径  string
     */
    headImagePath: null,
    /**
     * nickName 好友 性别 string
     */
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemCount = data.readInt();
        if (this.itemCount != 0) {
            for (var a = 0; a < this.itemCount; a++) {
                this.friends[a] = this.getFriendInfo(data);
            }
        }
    },

    getFriendInfo: function (data) {
        this.diamond = data.readInt();
        this.voucher = data.readInt();
        this.friendID = data.readULong64();
        this.gold = data.readInt();
        this.headImageID = data.readULong64();
        this.gender = data.readMyString();
        this.headImagePath = data.readMyString();
        this.nickName = data.readMyString();

        var friend = [this.diamond, this.voucher, this.friendID, this.gold,
            this.headImageID, this.gender, this.headImagePath, this.nickName];

        return friend;
    }
});


/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.EditFriend = netStruct.NetStruct.extend({
    /**
     * result 结果 byte   1:申请成功 2:已经申请过 3:已经是好友 4:自己好友上限 5:删除好友成功 6:删除好友失败
     */
    result: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.result = data.readByte();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.FriendVerify = netStruct.NetStruct.extend({
    /**
     * itemCount 消息个数 int
     */
    itemCount: null,
    /**
     * verifies 验证信息集合
     */
    verifies: [],
    /**
     * userID 用户ID 登陆用
     */
    userID: [],
    /**
     * friendID 好友ID 显示用
     */
    friendID: null,
    /**
     * nickName 昵称 string
     */
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemCount = data.readInt();
        if (this.itemCount != 0) {
            for (var a = 0; a < this.itemCount; a++) {
                this.verifies[a] = this.getVerifiesInfo(data);
            }
        }
    },

    getVerifiesInfo: function (data) {
        this.userID = data.readLong();
        this.friendID = data.readULong64();
        this.nickName = data.readMyString();

        var verify = [this.userID, this.friendID, this.nickName];

        return verify;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.FriendResponse = netStruct.NetStruct.extend({
    /**
     * responseType 响应类型  int
     */
    responseType: null,
    /**
     * itemCount 集合长度  int
     */
    itemCount: null,
    /**
     * friends friends集合
     */
    friends: [],
    /**
     * diamond 好友 钻石 int
     */
    diamond: null,
    /**
     * voucher 好友 兑换券 int
     */
    voucher: null,
    /**
     * friendID 好友ID long
     */
    friendID: null,
    /**
     * gold 好友 金币 int
     */
    gold: null,
    /**
     * headImageID 好友 头像ID long
     */
    headImageID: null,
    /**
     * gender 好友 性别 string
     */
    gender: null,
    /**
     * headImagePath 好友 头像路径  string
     */
    headImagePath: null,
    /**
     * nickName 好友 性别 string
     */
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.responseType = data.readInt();
        this.itemCount = data.readInt();
        if (this.itemCount != 0) {
            for (var a = 0; a < this.itemCount; a++) {
                this.friends[a] = this.getFriendInfo(data);
            }
        }
    },

    getFriendInfo: function (data) {
        this.diamond = data.readInt();
        this.voucher = data.readInt();
        this.friendID = data.readULong64();
        this.gold = data.readInt();
        this.headImageID = data.readULong64();
        this.gender = data.readMyString();
        this.headImagePath = data.readMyString();
        this.nickName = data.readMyString();

        var friend = [this.diamond, this.voucher, this.friendID, this.gold,
            this.headImageID, this.gender, this.headImagePath, this.nickName];

        return friend;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.SearchFriend = netStruct.NetStruct.extend({
    /**
     * diamond 好友 钻石 int
     */
    diamond: null,
    /**
     * voucher 好友 兑换券 int
     */
    voucher: null,
    /**
     * friendID 好友ID long
     */
    friendID: null,
    /**
     * gold 好友 金币 int
     */
    gold: null,
    /**
     * headImageID 好友 头像ID long
     */
    headImageID: null,
    /**
     * gender 好友 性别 string
     */
    gender: null,
    /**
     * headImagePath 好友 头像路径  string
     */
    headImagePath: null,
    /**
     * nickName 好友 性别 string
     */
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.voucher = data.readInt();
        this.friendID = data.readULong64();
        this.gold = data.readInt();
        this.headImageID = data.readULong64();
        this.gender = data.readMyString();
        this.headImagePath = data.readMyString();
        this.nickName = data.readMyString();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetTalk = netStruct.NetStruct.extend({
    /**
     * chatType 聊天类型 int  1 私聊  2 公聊
     */
    chatType: null,
    /**
     * toUserID 对方的id long
     */
    toUserID: null,
    isVip:null,
    /**
     * userID 说话人id long
     */
    userID: null,
    
    /**
     * content 内容 string
     */
    content: null,
    /**
     * toNickName 对方的nickname string
     */
    toNickName: null,
    
    headPath:null,
    /**
     * nickName 昵称 string
     */
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.chatType = data.readInt();
        this.toUserID = data.readLong();
        this.isVip = data.readBoolean();
        this.userID = data.readLong();
        this.content = data.readMyString();
        this.toNickName = data.readMyString();
        this.headPath = data.readMyString();
        this.nickName = data.readMyString();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.HistoryTalk = netStruct.NetStruct.extend({
    /**
     * itemCount 记录条数 int
     */
    itemCount: 0,
    /**
     * talks 聊天记录数组
     */
    talks: [],
    /**
     * chatType 聊天类型 int  1 私聊  2 公聊  3系统
     */
    chatType: null,
    isVip:null,
    /**
     * userID 说话人id long
     */
 
    userID: null,
    /**
     * content 内容 string
     */
  
    content: null,
    /**
     * nickName 昵称 string
     */
    headPath:null,
    nickName: null,
    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemCount = data.readInt();
        if (this.itemCount != 0) {
            for (var a = 0; a < this.itemCount; a++) {
                this.talks[a] = this.getHistoryTalk(data);
            }
        }
    },

    getHistoryTalk: function (data) {
    	this.chatType = data.readInt();
    	this.isVip = data.readBoolean();
        this.userID = data.readLong();
        this.content = data.readMyString();
        this.headPath = data.readMyString();
        this.nickName = data.readMyString();
//        var talk = [this.chatType, this.userID, this.isVip,this.content,this.headPath, this.nickName];
        var talk = [this.chatType, this.userID,this.content, this.nickName];
        return talk;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetMailList = netStruct.NetStruct.extend({
    /**
     * mailType 邮件类型  int
     */
    mailType: null,
    /**
     * itemCount 附件集合长度  int
     */
    itemCount: null,
    /**
     * mails 邮件集合  int
     */
    mails: [],
    /**
     * hasAttachment 是否有附件  int   1 有附件 0 无附件
     */
    hasAttachment: null,
    /**
     * isRead 是否读过  int   0 未读 1 已读  2已领
     */
    isRead: null,
    /**
     * mailID 邮件ID  long
     */
    mailID: null,
    /**
     * senderType 发件人类型  0:用户 1:管理员 2:系统   int
     */
    senderType: null,
    /**
     * creatDate 创建日期  string
     */
    createDate: null,
    headPath:null,
    /**
     * title 标题  string
     */
    title: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.mailType = data.readInt();
        this.itemCount = data.readInt();
        if (this.itemCount != 0) {
            for (var a = 0; a < this.itemCount; a++) {
                this.mails[a] = this.getMails(data);
            }
        }
    },

    getMails: function (data) {
        this.hasAttachment = data.readInt();
        this.isRead = data.readInt();
        this.mailID = data.readULong64();
        this.senderType = data.readInt();
        this.creatDate = data.readMyString();
        this.headPath = data.readMyString();
        this.title = data.readMyString();

        var mail = [this.hasAttachment, this.isRead, this.mailID, this.senderType, this.creatDate, this.headPath,this.title];

        return mail;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.MailEdit = netStruct.NetStruct.extend({
    /**
     * editType 编辑类型 int
     */
    editType: null,
    /**
     * diamond 钻石 int
     */
    diamond: null,
    /**
     * 参赛券
     */
    cansaiquan: null,
    /**
     * voucher 兑换券 int
     */
    voucher: null,
    /**
     * gold 金币 int
     */
    gold: null,
    /**
     * result 结果 int
     */
    result: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.editType = data.readInt();
        this.diamond = data.readInt();
        this.cansaiquan = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.result = data.readInt();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetMailInfo = netStruct.NetStruct.extend({
    /**
     * senderID 发件人ID  long
     */
    senderID: null,
    /**
     * isRead 是否读过  int
     */
    isRead: null,
    /**
     * mailID 邮件ID  long
     */
    mailID: null,
    /**
     * receiverID 收件人ID  long
     */
    receiverID: null,
    /**
     * senderType 发件人类型  0:用户 1:管理员 2:系统   int
     */
    senderType: null,
    /**
     * content 内容  string
     */
    content: null,
    /**
     * createDate 创建日期  string
     */
    createDate: null,
    /**
     * senderName 发件人昵称  string
     */
    senderName: null,
    /**
     * attachmentCount 附件集合长度  int
     */
    attachmentCount: null,
    /**
     * attachments 附件集合
     */
    attachments: [],
    /**
     * attachmentID 附件id  int
     */
    attachmentID: null,
    /**
     * attachmentQuantity 附件数量 int
     */
    attachmentQuantity: null,
    /**
     * receiverName 收件人昵称  string
     */
    receiverName: null,
    /**
     * title 标题  string
     */
    title: null,

    readBody: function (data) {
//    	cc.log("GetMailInfo readBody");
    	
        if (data.length == 0)
            return;
        this.senderID = data.readULong64();
        this.isRead = data.readInt();
        this.mailID = data.readULong64();
        this.receiverID = data.readULong64();
        this.senderType = data.readInt();
        this.content = data.readMyString();
        this.createDate = data.readMyString();
        this.senderName = data.readMyString();
        this.attachmentCount = data.readInt();
        if (this.attachmentCount != 0) {
            for (var a = 0; a < this.attachmentCount; a++) {
                this.attachments[a] = this.getAttachments(data);
            }
        }
        this.receiverName = data.readMyString();
        this.title = data.readMyString();

        var mail = [this.senderID, this.isRead, this.mailID, this.receiverID, this.senderType, this.content,
            this.creatDate, this.senderName, this.attachments, this.receiverName, this.title];

        return mail;
    },

    getAttachments: function (data) {
        this.attachmentID = data.readInt();
        this.attachmentQuantity = data.readInt();

        var attachment = [this.attachmentID, this.attachmentQuantity];

        return attachment;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.SendMail = netStruct.NetStruct.extend({
    /**
     * result int   <0 成功  >=0 失败，当日还剩额度
     */
    result: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.result = data.readInt();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GoldEgg = netStruct.NetStruct.extend({
    /**
     * diamond int
     */
    diamond: null,
    /**
     * cansaiquan int
     */
    cansaiquan: null,
    /**
     * voucher int
     */
    voucher: null,
    /**
     * gold int
     */
    gold: null,
    /**
     * result byte
     */
    result: null,
    /**
     * 砸金蛋奖励次数 int
     */
    itemCount: null,
    /**
     * 砸金蛋奖励
     */
    reward: [],
    /**
     * 奖励ID int
     */
    rewardId: null,
    /**
     * 奖励数量 int
     */
    rewardCount: null,
    ///**
    // * id int 商品id
    // */
    //id: null,
    ///**
    // * count int
    // */
    //itemCount: null,

    readBody: function (data) {
//    	console.log("解析之前"+data.bytesAvailable);
        if (data.length == 0)
            return;
        this.diamond = data.readInt();
        this.cansaiquan = data.readInt();
        this.voucher = data.readInt();
        this.gold = data.readInt();
        this.result = data.readByte();
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount / 2; a++) {
            this.reward[a] = this.getReward(data);
        }
        console.log("解析之后"+this.reward.length);
        //this.id = data.readInt();
        //this.itemCount = data.readInt();
    },

    getReward: function (data) {
        this.rewardId = data.readInt();
        this.rewardCount = data.readInt();

        var reward = [this.rewardId, this.rewardCount];

        return reward;
    }
});


/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.CanGoldEgg = netStruct.NetStruct.extend({
    /**
     * 今天砸蛋次数  byte
     */
    itemCount: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemCount = data.readByte();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.EggNameList = netStruct.NetStruct.extend({
    /**
     * 今天砸蛋次数  int
     */
    itemCount: null,
    /**
     * 今天砸蛋次数  []
     */
    itemLists: [],
    /**
     * 图标ID  int
     */
    goodIconID: null,
    /**
     * 商品ID  long
     */
    goodID: null,
    /**
     * 中奖人ID  long
     */
    userID: null,
    /**
     * 商品名字  string
     */
    goodName: null,
    /**
     * 昵称  string
     */
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount; a++) {
            this.itemLists[a] = this.getNameLists(data);
        }
    },

    getNameLists: function (data) {
        this.goodIconID = data.readInt();
        this.goodID = data.readULong64();
        this.userID = data.readLong();
        this.goodName = data.readMyString();
        this.nickName = data.readMyString();

        var nameList = [this.goodIconID, this.goodID, this.userID, this.goodName, this.nickName];

        return nameList;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.Pochan = netStruct.NetStruct.extend({
    /**
     * 结果 1：成功  0：失败   没有内容已领3次  byte
     */
    result: null,
    /**
     * 金币 int
     */
    gold: null,
    /**
     * 破产领取次数  int
     */
    pochanCount: null,

    readBody: function (data) {
        if (data.length == 0)
            this.result = 2;
        else {
            this.result = data.readByte();
            this.gold = data.readInt();
            this.pochanCount = data.readInt();
        }
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.Ruchang = netStruct.NetStruct.extend({
    /**
     * 数量 itemCount int
     */
    itemCount: null,
    /**
     * roomData []
     */
    ruchangData: [],
    /**
     * 底注 int
     */
    baseScore: null,
    /**
     * 入场金币 int
     */
    limitScore: null,
    /**
     * 场内人数 int
     */
    peopleCount: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemCount = data.readInt();
        for (var a = 0; a < this.itemCount; a++) {
            this.ruchangData[a] = this.getRuchangData(data);
        }
    },

    getRuchangData: function (data) {
        this.baseScore = data.readInt();
        this.limitScore = data.readInt();
        this.peopleCount = data.readInt();

        var ruchangData = [this.baseScore, this.limitScore, this.peopleCount];

        return ruchangData;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.UserTalk = netStruct.NetStruct.extend({
    isSuccess: null,
    talkIndex: null,
    talkID: 0,

    readBody: function (data) {
        if (data.length == 0)
            this.isSuccess = false;
        else {
            this.isSuccess = true;
            this.talkIndex = data.readByte();
            this.talkID = data.readByte();
        }
    }
});


/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.InnerUserInfo = netStruct.NetStruct.extend({
    result: 0,
    loseCount: 0,
    pingCount: 0,
    winCount: 0,
    itemCount: 0,
    items: [],
    goodID: 0,
    goodIconID: 0,
    goodCount: 0,
    goodPrice: 0,
    goodType: 0,

    readBody: function (data) {
        if (data.length == 0) {
            this.result = 0;
        }
        else {
            this.result = 1;
            this.loseCount = data.readInt();
            this.pingCount = data.readInt();
            this.winCount = data.readInt();
            this.itemCount = data.readInt();
            for (var a = 0; a < this.itemCount; a++) {
                this.items[a] = this.getItems(data);
            }
        }
    },

    getItems: function (data) {
        this.goodID = data.readInt();
        this.goodIconID = data.readInt();
        this.goodCount = data.readInt();
        this.goodPrice = data.readInt();
        this.goodType = data.readInt();

        var item = [this.goodID, this.goodIconID, this.goodCount, this.goodPrice, this.goodType];

        return item;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GameNotice = netStruct.NetStruct.extend({
    isReadDdzMission: 0,
    isReadSocial: 0,
    isReadMjMission: 0,
    isReadMail: 0,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.isReadDdzMission = data.readInt();
        this.isReadSocial = data.readInt();
        this.isReadMjMission = data.readInt();
        this.isReadMail = data.readInt();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.RestTime = netStruct.NetStruct.extend({
    /**
     * 倒计时类型 1砸金蛋， 2 雀神，地主赛开始倒计时 ，3 雀神，地主赛结束倒计时
     */
    itemType: 0,
    /**
     * 倒计时秒
     */
    timeSec: 0,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemType = data.readInt();
        this.timeSec = data.readInt();
    }
});


/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.Gonggao = netStruct.NetStruct.extend({
    /**
     * itemType int
     */
    itemType: null,
    /**
     * info string 左侧实时公告，长string
     */
    itemInfo: null,
    /**
     * 集合个数 int
     */
    itemCount: null,
    /**
     * 集合 []
     */
    notices: [],
    /**
     * 公告图标id int
     */
    noticeIconID: null,
    /**
     * 公告id long
     */
    noticeID: null,
    /**
     * 内容 string
     */
    content: null,
    /**
     * 活动结束时间 string
     */
    endDate: null,
    /**
     * 活动开始时间 string
     */
    startDate: null,
    /**
     * 标题 string
     */
    title: null,
    /**
     * 更多详情 string
     */
    moreContent: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.itemType = data.readInt();
        if (this.itemType == 1) {
            this.itemInfo = data.readLongString();
            this.itemCount = data.readInt();
            for (var a = 0; a < this.itemCount; a++) {
                this.notices[a] = this.getNotices(data);
            }
        }
        if (this.itemType == 2) {
            this.moreContent = data.readLongString();
        }
    },

    getNotices: function (data) {
        this.noticeIconID = data.readInt();
        this.noticeID = data.readULong64();
        this.content = data.readMyString();
        this.title = data.readMyString();

        var notice = [this.noticeIconID, this.noticeID, this.content, this.title];

        return notice;
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetQQ = netStruct.NetStruct.extend({
    content: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.content = data.readLongString();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetWX = netStruct.NetStruct.extend({
    result: null,//1 可以加钱  0 不加钱

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.result = data.readByte();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.JiHuo = netStruct.NetStruct.extend({
    result: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.result = data.readByte();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetVIPDays = netStruct.NetStruct.extend({
    days: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.days = data.readInt();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GameKick = netStruct.NetStruct.extend({
    result: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.result = data.readByte();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GameCheat = netStruct.NetStruct.extend({
    /**
     * type byte 0 其他问题 1 支付问题 2玩牌问题 3游戏故障 4 举报
     */
    type: null,
    result: null,

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.type = data.readInt();
        this.result = data.readByte();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.Register = netStruct.NetStruct.extend({
    result: null,
    userID: [],
    userName: "",
    password: "",

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.result = data.readByte();
        this.userID = data.readLong();
        this.userName = data.readMyString();
        this.password = data.readMyString();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.Login = netStruct.NetStruct.extend({
    islog: null,
    pochanCount: null,
    shuCount: null,
    diamond: null,
    voucher: null,
    pingCount: null,
    gold: null,
    grade: null,
    headImageID: null,
    isFeng: null,
    isBuyOne: null,
    isChange: null,
    isBuyNew: null,
    isReconnect: null,
    isSign: null,
    isKickEgg: null,
    isVip: null,
    isInEgg: null,
    userID: [],
    userIDShow: null,
    vipDays: null,
    shengCount: null,
    gender: null,
    headImagePath: null,
    nickName: null,

    readBody: function (data) {
        if (data.length == 0)
            this.islog = 0;
        else {
            this.pochanCount = data.readByte();
            this.shuCount = data.readInt();
            this.diamond = data.readInt();
            this.voucher = data.readInt();
            this.pingCount = data.readInt();
            this.gold = data.readInt();
            this.grade = data.readInt();
            this.headImageID = data.readULong64();
            this.isFeng = data.readBoolean();
            this.isBuyOne = data.readBoolean();
            this.isChange = data.readBoolean();
            this.isBuyNew = data.readBoolean();
            this.isReconnect = data.readBoolean();
            this.isSign = data.readBoolean();
            this.isKickEgg = data.readBoolean();
            this.isVip = data.readBoolean();
            this.isInEgg = data.readBoolean();
            this.userID = data.readLong();
            this.userIDShow = data.readArrayToLong(this.userID);
            this.vipDays = data.readInt();
            this.shengCount = data.readInt();
            this.gender = data.readMyString();
            this.headImagePath = data.readMyString();
            this.nickName = data.readMyString();
        }
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.Account = netStruct.NetStruct.extend({
    accountType: null,  //1:绑定成功  2:用户名已被使用  3:修改密码成功  4:用户名或密码错误  5:修改信息成功  6:昵称重复

    readBody: function (data) {
        if (data.length == 0)
            return;
        this.accountType = data.readByte();
    }
});

///**
// * @class
// * @extends netStruct.NetStruct
// */
//netStruct.ChangeInfo = netStruct.NetStruct.extend({
//    changeType: null,
//
//    readBody: function (data) {
//        if (data.length == 0) {
//            this.changeType = 0;
//        }
//        this.changeType = data.readByte();
//    }
//});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.LogonFinish = netStruct.NetStruct.extend({});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.ServerInfo = netStruct.NetStruct.extend({

    /**
     * 游戏ID
     */
    kindID: 0,
    /**
     * 服务器类型 constant.EnumConstant GAME_GENRE_*
     */
    serverType: 0,
    /**
     * 房间内桌子数量
     */
    tableCount: 0,
    /**
     * 桌子上椅子数量
     */
    chairCount: 0,
    serverID: 0,

    /**
     * @param {xinyou.Packet} data
     */
    readBody: function (data) {
        this.serverID = data.readUnsignedShort();
        this.kindID = data.readUnsignedShort();
        this.serverType = data.readUnsignedShort();
        this.tableCount = data.readUnsignedShort();
        this.chairCount = data.readUnsignedShort();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetTableListInfo = netStruct.NetStruct.extend({
    tableList: [],

    /**
     * @param {xinyou.Packet} data
     */
    readBody: function (data) {
        var tableCount = data.readUnsignedInt();
        var i;
        for (i = 0; i < tableCount; i++) {
            /**
             * @type {vo.Table}
             */
            var table = new vo.Table();
            table.id = i;
            table.locked = data.readBoolean();
            table.started = data.readBoolean();
            table.sitCondition = data.readBoolean();
            table.sitConditionValue = data.readUnsignedInt();

            this.tableList[i] = table;
        }
    }
});
/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.TableStatus = netStruct.NetStruct.extend({
    /**
     * 桌子ID
     */
    tableID: 0,
    /**
     * 游戏状态（游戏中1， 空闲0）
     */
    state: 0,
    /**
     * 密码状态（有密码1，无密码0）
     */
    havePassword: 0,
    /**
     * 游戏币限制状态（有限制1，无限制0）
     */
    haveSitCondition: 0,
    /**
     * 限制最低游戏币
     */
    sitConditionValue: 0,

    readBody: function (data) {
        this.tableID = data.readUnsignedShort();
        this.havePassword = data.readUnsignedByte();
        this.state = data.readUnsignedByte();
        this.haveSitCondition = data.readUnsignedByte();
        this.sitConditionValue = data.readUnsignedInt();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.SystemNotice = netStruct.NetStruct.extend({
    /**
     * 消息类型 constant.EnumConstant SMT_*
     */
    type: 0,
    /**
     * 消息内容
     */
    content: '',

    readBody: function (data) {
        this.type = data.readUnsignedShort();
        this.content = data.readString();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GetUserItem = netStruct.NetStruct.extend({
    userList: [],

    readBody: function (data) {
        var userCount = data.readUnsignedShort();
        var i;
        for (i = 0; i < userCount; i++) {
            /**
             * @type {vo.UserItem}
             */
            var userItem = new vo.UserItem();
            userItem.deserialize(data);
            this.userList[i] = userItem;

            if (xinyou.gameFrame.meFromLogin.userId == userItem.id) {
                xinyou.gameFrame.me = userItem;
                //xinyou.gameFrame.gameStatus = userItem.wTableID != XYConstant.INVALID_TABLE_ID ? 1 : 0;
            }
        }
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.UserBannedStatus = netStruct.NetStruct.extend({
    /**
     * 禁言时长(秒)
     */
    bannedTime: 0,

    readBody: function (data) {
        this.bannedTime = data.readUnsignedInt();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.UserSitFailed = netStruct.NetStruct.extend({
    /**
     * 失败类型:2积分不足,1银两不足,0其他
     */
    reason: 0,
    /**
     * 错误描述
     */
    content: '',

    readBody: function (data) {
        this.reason = data.readUnsignedByte();
        this.content = data.readString();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.UserStatus = netStruct.NetStruct.extend({
    /**
     * 用户ID
     */
    userID: 0,
    /**
     * 桌子ID
     */
    tableID: 0,
    /**
     * 椅子ID
     */
    chairID: 0,
    /**
     * 网络延迟
     */
    netDelay: 0,
    /**
     * 用户状态 constant.EnumConstant US_*
     */
    status: 0,

    readBody: function (data) {
        this.userID = data.readUnsignedInt();
        this.tableID = data.readUnsignedShort();
        this.chairID = data.readUnsignedShort();
        this.netDelay = data.readUnsignedShort();
        this.status = data.readUnsignedByte();
    }
});
/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.UserScoreMSG = netStruct.NetStruct.extend({
    /**
     * 用户ID
     */
    dwUserID: 0,
    /**
     * 积分信息
     * @type vo.UserScore
     */
    userScore: null,
    /**
     * 魅力值
     */
    lCharm: 0,
    /**
     * 当前类型总局数
     */
    lGameCount: 0,
    /**
     * 所有类型总局数(银两,积分)
     */
    lGameCount_All: 0,
    /**
     * 打工局数
     */
    lWorkCount: 0,

    readBody: function (data) {
        this.dwUserID = data.readUnsignedInt();
        this.userScore = new vo.UserScore();
        this.userScore.deserialize(data);
        this.lCharm = data.readInt();
        this.lGameCount = data.readInt();
        this.lGameCount_All = data.readInt();
        this.lWorkCount = data.readInt();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.OnlineCntInfoMSG = netStruct.NetStruct.extend({
    onlineInfo: [],

    readBody: function (data) {
        while (data.bytesAvailable) {
            /**
             * @type {vo.OnlineCntInfo}
             */
            var onlineCntInfo = new vo.OnlineCntInfo();
            onlineCntInfo.deserialize(data);
            this.onlineInfo.push(onlineCntInfo);
        }
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GS_Message = netStruct.NetStruct.extend({
    type: 0,
    length: 0,
    content: '',

    readBody: function (data) {
        this.type = data.readUnsignedShort();
        this.length = data.readUnsignedShort();
        this.content = data.readString();
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.UserChat = netStruct.NetStruct.extend({
    /**
     * @type vo.ChatInfo
     */
    chatInfo: null,

    readBody: function (data) {
        this.chatInfo = new vo.ChatInfo();
        this.chatInfo.deserialize(data);
    }
});

/**
 * @class
 * @extends netStruct.NetStruct
 */
netStruct.GS_EX_Option = netStruct.NetStruct.extend({
    /**
     * 游戏状态
     */
    cbGameStatus: 0,
    /**
     * 允许旁观
     */
    cbAllowLookon: false,

    readBody: function (data) {
        this.cbGameStatus = data.readUnsignedByte();
        this.cbAllowLookon = data.readUnsignedByte() != 0;
        //			data.readShort();
    }
});

/**
 * @class
 * @extends cc.Class
 */
vo.Table = cc.Class.extend({
    id: 0,
    /**
     * 桌子是否锁定
     * @type Boolean
     */
    locked: false,
    /**
     * 桌子是否开始游戏
     * @type Boolean
     */
    started: false,
    /**
     * 桌子是否有坐下限定
     * @type Boolean
     */
    sitCondition: false,
    /**
     * 桌子坐下限定的银两(或积分)
     */
    sitConditionValue: 0,

    ctor: function () {
        this.locked = false;
        this.started = false;
        this.sitCondition = false;
        this.sitConditionValue = 0;
    }
});

vo.LoginInfo = {
    userId: 0,
    /**
     * 头像地址
     */
    faceUrl: "",
    /**
     * 奖牌
     */
    medals: 0,
    /**
     * 金币
     */
    money: 0,
    /**
     * 昵称
     */
    nickName: "",
    /**
     * 密码
     */
    pwd: "",
    /**
     * 银两
     */
    score: 0,
    /**
     * vip等级
     */
    vip: 0
};

/**
 * @class
 * @extends vo.BaseStruct
 * @property {boolean} isLookOn 是否旁观
 */
vo.UserItem = vo.BaseStruct.extend({
    /**
     * 头像索引
     */
    wFaceID: 0,
    /**
     * 用户性别 (0女 男1)
     */
    cbGender: 0,
    /**
     * 会员等级
     */
    cbMember: 0,
    /**
     * 爵位
     */
    lCharm: 0,
    /**
     * 用户 I D
     */
    id: 0,
    /**
     * 社团索引
     */
    dwGroupID: 0,
    /**
     * 用户等级
     */
    dwUserRight: 0,
    /**
     * 管理权限
     */
    dwMasterRight: 0,
    /**
     * 帐号
     * @type String
     */
    szAccount: '',
    /**
     * 昵称
     * @type String
     */
    nickName: '',
    /**
     * 用户名
     * @type String
     */
    userName: '',
    /**
     * 社团名字
     * @type String
     */
    szGroupName: '',
    lBirthday_year: 0,
    lBirthday_month: 0,
    lBirthday_day: 0,
    /**
     * 游戏银两(积分游戏需要)
     */
    lGold: 0,
    /**
     * 游戏积分(如果是银两类型的房间,该值表示银两)
     */
    lScore: 0,
    /**
     * 胜利盘数
     */
    lWinCount: 0,
    /**
     * 失败盘数
     */
    lLostCount: 0,
    /**
     * 和局盘数
     */
    lDrawCount: 0,
    /**
     * 断线数目
     */
    lFleeCount: 0,
    /**
     * 用户经验
     */
    lExperience: 0,
    /**
     * 在线时长
     */
    onlineTime: 0,
    /**
     * 桌子号码
     */
    wTableID: XYConstant.INVALID_TABLE_ID,
    /**
     * 椅子位置
     */
    wChairID: XYConstant.INVALID_CHAIR_ID,
    /**
     * 网络延时
     */
    wNetDelay: 0,
    /**
     * 用户状态 constant.EnumConstant US_*
     */
    cbUserStatus: 0,
    /**
     * 用户关系
     */
    cbCompanion: 0,
    /**
     * 博客
     * @type String
     */
    szBlog: '',
    /**
     * 比赛名次
     */
    lPlace: 0,
    /**
     * 报名序号
     */
    lRegisterID: 0,
    /**
     * 领取福利金的次数[当天]
     */
    dwWelfarismTime: 0,
    /**
     * 奖券数量
     */
    lLotteryCnt: 0,
    /**
     * 当前类型总局数
     */
    lGameCount: 0,
    /**
     * 所有类型总局数(甜豆,积分)
     */
    lGameCount_All: 0,
    /**
     * 打工类游戏的打工局数
     */
    lGameCount_Work: 0,
    /**
     * 新邮件数
     */
    lNewMailCount: 0,
    /**
     * 省
     * @type String
     */
    Region0: '',
    /**
     * 市
     * @type String
     */
    Region1: '',

    ctor: function () {
        cc.defineGetterSetter(this, 'isLookOn', this.isLookOnGetter);
    },

    isLookOnGetter: function () {
        return this.cbUserStatus == EnumConstant.US_LOOKON;
    },

    serialize: function (data) {
        data = this._super(data);
        data.writeShort(this.wFaceID);
        data.writeByte(this.cbGender);
        data.writeByte(this.cbMember);
        data.writeUnsignedInt(this.lCharm);
        data.writeUnsignedInt(this.id);
        data.writeUnsignedInt(this.lBirthday_year);
        data.writeByte(this.lBirthday_month);
        data.writeByte(this.lBirthday_day);
        data.writeShort(this.wTableID);
        data.writeShort(this.wChairID);
        data.writeShort(this.wNetDelay);
        data.writeByte(this.cbUserStatus);
        data.writeUnsignedInt(this.dwUserRight);
        data.writeUnsignedInt(this.dwMasterRight);
        data.writeUnsignedInt(this.lGold);
        data.writeInt(this.lScore);
        data.writeUnsignedInt(this.lWinCount);
        data.writeUnsignedInt(this.lLostCount);
        data.writeUnsignedInt(this.lDrawCount);
        data.writeUnsignedInt(this.lFleeCount);
        data.writeUnsignedInt(this.lExperience);
        data.writeUnsignedInt(this.onlineTime);
        data.writeUnsignedInt(this.lGameCount_Work);
        data.writeUnsignedInt(this.lLotteryCnt);
        data.writeUnsignedInt(this.lGameCount);
        data.writeUnsignedInt(this.lGameCount_All);
        data.writeUnsignedInt(this.lNewMailCount);
        data.writeString(this.szAccount);
        data.writeString(this.nickName);
        data.writeString(this.szBlog);
        data.writeString(this.Region0);
        data.writeString(this.Region1);

        return data;
    },

    deserialize: function (data) {
        this.wFaceID = data.readUnsignedShort();
        this.cbGender = data.readByte();
        this.cbMember = data.readUnsignedByte();
        this.lCharm = data.readUnsignedInt();
        this.id = data.readUnsignedInt();
        this.lBirthday_year = data.readUnsignedInt();
        this.lBirthday_month = data.readByte();
        this.lBirthday_day = data.readByte();
        this.wTableID = data.readUnsignedShort();
        this.wChairID = data.readUnsignedShort();
        this.wNetDelay = data.readUnsignedShort();
        this.cbUserStatus = data.readByte();
        this.dwUserRight = data.readUnsignedInt();
        this.dwMasterRight = data.readUnsignedInt();
        this.lGold = data.readUnsignedInt();
        this.lScore = data.readInt();
        this.lWinCount = data.readUnsignedInt();
        this.lLostCount = data.readUnsignedInt();
        this.lDrawCount = data.readUnsignedInt();
        this.lFleeCount = data.readUnsignedInt();
        this.lExperience = data.readUnsignedInt();
        this.onlineTime = data.readUnsignedInt();
        this.lGameCount_Work = data.readUnsignedInt();
        this.lLotteryCnt = data.readUnsignedInt();
        this.lGameCount = data.readUnsignedInt();
        this.lGameCount_All = data.readUnsignedInt();
        this.lNewMailCount = data.readUnsignedInt();
        this.szAccount = data.readString();
        this.nickName = data.readString();
        this.szBlog = data.readString();
        this.Region0 = data.readString();
        this.Region1 = data.readString();
    }
});

/**
 * @class
 * @extends vo.BaseStruct
 */
vo.UserScore = vo.BaseStruct.extend({
    /**
     * 用户银两
     */
    lGold: 0,
    /**
     * 用户分数
     */
    lScore: 0,
    /**
     * 胜利盘数
     */
    lWinCount: 0,
    /**
     * 失败盘数
     */
    lLostCount: 0,
    /**
     * 和局盘数
     */
    lDrawCount: 0,
    /**
     * 断线数目
     */
    lFleeCount: 0,
    /**
     * 用户经验(比赛房间里代表总局数)
     */
    lExperience: 0,
    deserialize: function (data) {
        this.lGold = data.readInt();
        this.lScore = data.readInt();
        this.lWinCount = data.readInt();
        this.lLostCount = data.readInt();
        this.lDrawCount = data.readInt();
        this.lFleeCount = data.readInt();
        this.lExperience = data.readInt();
    }
});

/**
 * @class
 * @extends vo.BaseStruct
 */
vo.OnlineCntInfo = vo.BaseStruct.extend({
    /**
     * 类型号码
     */
    wTypeID: 0,
    /**
     * 类型标识
     */
    wKindID: 0,
    /**
     * 在线人数
     */
    dwOnlineCnt: 0,

    deserialize: function (data) {
        this.wTypeID = data.readUnsignedShort();
        this.wKindID = data.readUnsignedShort();
        this.dwOnlineCnt = data.readUnsignedInt();
    }
});

/**
 * @class
 * @extends vo.BaseStruct
 */
vo.ChatInfo = vo.BaseStruct.extend({
    /**
     * 音效人索引(如果为-1,表示没有音效)
     */
    sAudioManIndex: -1,
    /**
     * 音效ID
     */
    sPhraseID: 0,

    /**
     * 信息长度
     */
    wChatLength: 0,
    /**
     * 信息颜色
     */
    crFontColor: 0,
    /**
     * 发送用户
     */
    dwSendUserID: 0,
    /**
     * 目标用户
     */
    dwTargetUserID: 0,
    /**
     * 聊天信息
     */
    szChatMessage: '',

    deserialize: function (data) {
        this.sAudioManIndex = data.readShort();
        this.sPhraseID = data.readShort();
        this.wChatLength = data.readShort();
        data.readShort();
        this.crFontColor = data.readInt();
        this.dwSendUserID = data.readInt();
        this.dwTargetUserID = data.readInt();
        this.szChatMessage = data.readString();
    },

    serialize: function (data) {
        data = this._super(data);
        data.writeShort(this.sAudioManIndex);
        data.writeShort(this.sPhraseID);
        data.writeShort(this.wChatLength + 1);
        data.writeShort(0);
        data.writeInt(this.crFontColor);
        data.writeInt(this.dwSendUserID);
        data.writeInt(this.dwTargetUserID);
        data.writeString(this.szChatMessage);

        return data;
    }
});

netStruct.User = netStruct.NetStruct.extend({
    id: 0,

    headId: 1,

    gender: 0,

    isVip: 0,

    wChairID: 0,

    lScore: 0,

    nickName: "",

    headImgUrl: "",

    status: 0,

    readBody: function (data) {
        this.gender = data.readByte();
        this.headId = data.readInt();
        this.id = data.readInt();
        this.isVip = data.readBoolean();
        this.wChairID = data.readByte();
        this.lScore = data.readInt();
        this.status = data.readByte();
        this.headImgUrl = data.readMyString();
        this.nickName = data.readFirstStr();
    }
});